<template>
  <view class="contain" style="background-color: #fff">
    <!-- 头部导航栏 -->
    <view class="navbar" :style="{ paddingTop: menu.top + 'px' }">
      <image src="http://xcxtp.njmswl.com/images/goBack.png" class="goBack" @tap="goBack" />
      <text class="title">蓝鸽房产</text>
    </view>
    <scroll-view class="scroll-view Poster" scroll-y>
      <image class="poster" src="http://xcxtp.njmswl.com/images/820140703.png" />
      <view class="title2">蓝鸽房产</view>
      <view class="save">长按保存</view>
      <view class="tag">买房、租房请联系我</view>
      <img :src="a" show-menu-by-longpress class="code" mode="scaleToFill" />
      <view>
        <image :src="imgUrl" class="profileImg" />
      </view>
      <view class="nikname">{{ mobile }}</view>
    </scroll-view>
  </view>
</template>
<script setup>
import { getUserCode } from '@/services/index'
import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { getInformationAPI } from '../../services/information'
import { getUserInformationAPI } from '@/services/profile'
// 定义响应式数据
const menu = ref({})
const detailId = ref()

const InformationList = ref()
const getInformationList = async () => {
  console.log('aaaaaa', typeof parseInt(detailId.value))
  const res = await getInformationAPI({ id: parseInt(detailId.value) })
  InformationList.value = res.data
  console.log('dasdsadasdasd', InformationList.value)
}

const imgUrl = ref('')
const mobile = ref('')
const nickName = ref('')
onLoad(() => {
  getUserCodeFun()
  getUserInformation()
})
//获取用户二维码
const a = ref()
const getUserCodeFun = async () => {
  const res = await getUserCode({})
  a.value = 'data:image/png;base64,' + res.data
}

// 方法定义
const goBack = () => {
  uni.navigateBack()
}

onLoad(async (options) => {
  console.log('fffffffffffffffff', options.id)
  detailId.value = options.id
  menu.value = uni.getMenuButtonBoundingClientRect()
  await getInformationList()
})

//uniapp微信小程序分享页面到微信好友

onShareAppMessage(() => {})

const getUserInformation = async () => {
  const userid = uni.getStorageSync('appIdKey')
  console.log('获取个人信息这个函数执行了嘛')
  const res = await getUserInformationAPI({
    // id:userid
  })
  console.log('看这里》》打印个人信息', res)
  imgUrl.value = res.data?.avatar
  mobile.value = res.data?.mobile
  nickName.value = res.data?.nickname
  console.log('dsadsdsad', imgUrl.value)
}
//uniapp微信小程序分享页面到微信朋友圈

onShareTimeline(() => {})
</script>
<style lang="less">

.Poster{
width: 70%;
  height: 130%;
  margin: 60px auto;
}
.tag {
  font-size: 26rpx;
  color: #afa6a6;
  font-weight: 400;
  font-family: PingFang SC;
  position: absolute;
  top: 981rpx;
  left: 158rpx;
}
.save {
  font-size: 28rpx;
  color: #afa6a6;
  font-weight: 400;
  font-family: PingFang SC;
  position: absolute;
  top: 995rpx;
  left: 573rpx;
}
.title2 {
  font-size: 36rpx;
  font-weight: 800;
  font-family: PingFang SC;
  position: absolute;
  top: 800rpx;
  left: 36rpx;
}
.nikname {
  position: absolute;
  top: 929rpx;
  left: 156rpx;
}
.profileImg {
  position: absolute;
  top: 456px;
  left: 6px;
  border-radius: 50%;
  width: 100rpx;
  height: 100rpx;
  margin-left: 23rpx;
  margin-right: 24rpx;
}
.poster {
  width: 100%;
  height: 250px;
}
.code {
  width: 100px;
  height: 100px;
  position: absolute;
  top: 390px;
  right: 10px;
  z-index: 100;
}
page {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.scroll-view {
  position: relative;
  flex: 1;
}
.navbar {
  margin-top: 8rpx;
  padding-bottom: 49rpx;
  background-color: #fff;
  background-size: cover;
  position: relative;
  display: flex;
  flex-direction: column;

  .goBack {
    position: absolute;
    width: 18rpx;
    height: 30rpx;
    margin-left: 56rpx;
    margin-top: 9rpx;
  }

  .title {
    text-align: center;
    font-family: PingFang SC;
    font-weight: 600;
    font-size: 36rpx;
    color: #000000;
  }
}

.searchInput {
  border: 1px solid #ccc;
  width: 80%;
  margin: 0 auto;
  height: 70rpx;
  text-align: center;
}
</style>
